package com.jack.leetcode.eachproblem_2020;

/**
 * Created by zhang_j on 2020/11/7
 */
public class 区间和的个数 {

    public int countRangeSum(int[] nums, int lower, int upper) {
        if(nums == null){
            return 0;
        }
        int result = 0;
        int n = nums.length;
        for(int i = 0;i < n;i++){
            long tmp = 0;
            for(int j = i;j< n;j++){
                tmp += nums[j];
                if(tmp >= lower && tmp <= upper){
                    result++;
                }
            }
        }
        return result;
    }
}
